package com.lpc.android.abc;

import android.app.Application;

import com.lpc.android.abc.base.base.BaseApplication;
import com.squareup.leakcanary.LeakCanary;
import com.squareup.leakcanary.RefWatcher;


/**
 * Created by lpc on 2016/10/30.
 */

public class ABCApplication extends Application {

    private static RefWatcher refWatcher;

    public static RefWatcher getRefWatcher() {
        return refWatcher;
    }

    @Override
    public void onCreate() {
        super.onCreate();

        initLeakCanary();

        BaseApplication.onCreate(this);

    }

    private void initLeakCanary() {

        if (LeakCanary.isInAnalyzerProcess(this)) {
            // This process is dedicated to LeakCanary for heap analysis.
            // You should not init your app in this process.
            return;
        }
        refWatcher = LeakCanary.install(this);
    }

    @Override
    public void onTerminate() {
        super.onTerminate();
        BaseApplication.onTerminate();

        refWatcher = null;
    }
}
